package shop.up.all.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import shop.up.common.result.Result;
import shop.up.product.client.ProductFeignClient;

import javax.servlet.http.HttpServletRequest;

/**
 * 网站首页
 */
@Controller
public class IndexController {

    // @Qualifier("productDegradeFeignClient")
    @Autowired
    private ProductFeignClient productFeignClient;

    @GetMapping({"/","index.html"})
    public String index(HttpServletRequest request){
      // 获取首页分类数据
      Result result = productFeignClient.getBaseCategoryList();
      // 将数据设置到request请求域中
      request.setAttribute("list", result.getData());

      return "index/index";
  }
}
